import socket from "@/socket";

const actions = {
    login(context, data) {
        return new Promise((resolve, reject) => {
            socket.emit('login', data, res => resolve(res));
        })
    },
    signup(context, data) {
        return new Promise((resolve, reject) => {
            socket.emit('signup', data, res => resolve(res));
        })
    },
    // 获取好友列表
    getFriends(context, data) {
        return new Promise((resolve, reject) => {
            socket.emit('get_friend', data, res => resolve(res));
        })
    },
    // 获取群聊
    getGroupChats(context, data) {
        return new Promise((resolve, reject) => {
            socket.emit('get_groupChats', data, res => resolve(res));
        })
    },
    // 连接到群聊
    connectToGroupChats(context, data) {
        return new Promise((resolve, reject) => {
            socket.emit('connect_to_groupChats', data, res => resolve(res));
        })
    },
}

export default {
    namespaced: true,
    actions
}